Page({
  data:{
    books:[],
    texts:'',
    arr:wx.getStorageSync('arr')||[]
  },
  btnOk(){
    wx.showLoading({
      title: '加载中',
      mask:true,
    })
    wx.request({
      url: 'https://hmajax.itheima.net/api/books',
      method:'GET',
      data:{
        creator: 'zhangsan'
      },
      success:(res)=>{
        this.setData({books:res.data.data})
        wx.showToast({
          title: '加载成功',
          mask:true,
          duration:3000,
          icon:'none'
        })
      },
      complete(){
        wx.hideLoading()
      }
    })
  },
  setStorage(){
    wx.setStorageSync('user', {name:'张三',age:990})
    wx.setStorageSync('ccc', '菜成')
  },
  getStorage(){
    const user = wx.getStorageSync('user')
    console.log(user);
  },
  removeStorage(){
    wx.removeStorageSync('ccc')
  },
  clearStorage(){
    wx.clearStorageSync()
  },
  btnSosuo(){
    // console.log(1);
    const {arr , texts } = this.data
    arr.push(texts)
    this.setData({
      arr:arr,
      texts:''
    })
    wx.setStorageSync('arr', arr)
  },
  removeSto(){
    wx.removeStorageSync('arr')
    this.setData({
      arr:wx.getStorageSync('arr')||[]
    })
  }
})